﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="WCSFContrib.ECommerceCatalog.Product.Views.Product_Default"
    Title="Default" MasterPageFile="~/Shared/Default.master" %>

<%@ Register Src="~/Product/UserControls/ProductDetails.ascx" TagName="ProductDetails" TagPrefix="uc1" %>
<%@ Register Assembly="Microsoft.Practices.Web.UI.WebControls" Namespace="Microsoft.Practices.Web.UI.WebControls"
    TagPrefix="WebControls" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register Assembly="RealTimeSearch" Namespace="RealTimeSearch" TagPrefix="rts" %>

<asp:Content ID="content" ContentPlaceHolderID="DefaultContent" Runat="Server">
    <h1>Search Products</h1>
    
    <asp:panel ID="Panel1" runat="server">
        <asp:Label ID="ProductLabel" runat="server" Text="Search:" />
        <asp:TextBox ID="SearchTextBox" runat="server" OnTextChanged="SearchTextBox_OnTextChanged" />
        <%--<asp:ImageButton ID="SearchButton" runat="server" OnClick="SearchButton_Click" ImageUrl="~/Images/find.png" ImageAlign="AbsMiddle" />--%>
        
        <rts:RealTimeSearchMonitor ID="ProductRealTimeSearchMonitor" runat="server" Interval="700" AssociatedUpdatePanelID="ResultsUpdatePanel">
            <ControlsToMonitor>
                <rts:ControlMonitorParameter TargetId="SearchTextBox" />
            </ControlsToMonitor>
        </rts:RealTimeSearchMonitor>
    </asp:panel>
    
    <asp:UpdatePanel ID="ResultsUpdatePanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <br />
            <asp:GridView ID="ProductsGridView" runat="server" AutoGenerateColumns="False" DataSourceID="ProductsContainerDataSource"
                OnRowCommand="ProductsGridView_RowCommand" DataKeyNames="ItemId" AllowPaging="True"
                PageSize="3" EnableViewState="False" AllowSorting="True" EmptyDataText="No items found.">
                <Columns>
                    <asp:BoundField DataField="ItemId" HeaderText="ID" Visible="False" SortExpression="ItemId" />
                    <asp:ImageField DataImageUrlField="Image" NullDisplayText="no image" >
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="120px" />
                    </asp:ImageField>
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" >
                        <ItemStyle Width="300px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" HtmlEncode="False" DataFormatString="{0:C}" >
                        <ItemStyle Width="50px" />
                    </asp:BoundField>
                    <asp:ButtonField CommandName="ShowProductDetails" Text="Product Details" ButtonType="Image" ImageUrl="~/Images/details.png" >
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    </asp:ButtonField>
                </Columns>
                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:GridView>
            
            <br />
            
            <asp:Label ID="NullControl" runat="server" /><%-- Non operational control required for the TargetControlID property of popup extender --%>
            <ajax:ModalPopupExtender ID="DetailsModalPopupExtender" runat="server" 
                                     TargetControlID="NullControl"
                                     PopupControlID="DetailsPopupPanel"
                                     CancelControlID="CloseButton"
                                     BackgroundCssClass="modalBackground"
                                     DropShadow="true" />
            <asp:Panel ID="DetailsPopupPanel" runat="server" Width="400px" BorderStyle="Outset" CssClass="modalPopup">
                <div>
                    <table width="100%">
                        <tr>
                            <td align="right" colspan="2">
                                <asp:Button ID="CloseButton" runat="server" style="text-align:center" Text="X" Width="20px" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <uc1:ProductDetails ID="ProductDetailsUserControl" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                Quantity: 
                                <asp:TextBox ID="QuantityTextBox" runat="server"
                                    Text="1" Width="30" style="text-align:center" />
                                <asp:ImageButton ID="DownImageButton" runat="server" ImageUrl="~/Images/down.gif"
                                    Width="15" Height="15"/>
                                <asp:ImageButton ID="UpImageButton" runat="server" ImageUrl="~/Images/up.gif"
                                    Width="15" Height="15"/>
                                
                                <ajax:NumericUpDownExtender ID="QuantityNumericUpDownExtender" runat="server"
                                    TargetControlID="QuantityTextBox" 
                                    Width="100"
                                    TargetButtonDownID="DownImageButton"
                                    TargetButtonUpID="UpImageButton"
                                    Minimum="1" />
                            </td>
                            <td align="right">
                                <asp:Button ID="AddCartButton" runat="server" Text="Add to Cart" OnClick="AddCartButton_Click" />
                            </td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
            <WebControls:ObjectContainerDataSource ID="ProductsContainerDataSource" runat="server"
                DataObjectTypeName="WCSFContrib.ECommerceCatalog.BusinessEntities.Item"
                OnSelecting="ProductsContainerDataSource_Selecting" />
        </ContentTemplate>
    </asp:UpdatePanel>
    
    <asp:UpdateProgress ID="ProductsUpdateProgress" runat="server" DisplayAfter="10" AssociatedUpdatePanelID="ResultsUpdatePanel">
        <ProgressTemplate>
            <asp:Image ID="LoadingImage" ImageUrl="../Images/ajax-loader.gif" runat="server" /> Loading...
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
